<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of AuthorizedController
 *
 * @author dung
 */
class AuthorizedController extends BaseController
{

    /**
     * Whitelisted auth routes.
     *
     * @var array
     */
    protected $whitelist = array();

    /**
     * Initializer.
     *
     * @return void
     */
    public function __construct()
    {
        // Apply the auth filter
        $this->beforeFilter('auth', array('except' => $this->whitelist));

        // Call parent
        parent::__construct();
    }

    public function pu()
    {
        $profile_id = $this->u->id;
        $uid = Jinput::get('uid');
        // need check exist user
        if ($uid && Permission::has_access('user', 'edit', $uid))
            $profile_id = $uid;

        return Sentry::findUserByID($profile_id);
    }

}
